package me.zhengjie.modules.quartz.task.pull;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.quartz.service.dto.SyncCommon;
import me.zhengjie.modules.sync.processing.PropertyContactSyncProcessing;
import me.zhengjie.modules.sync.processing.PropertyVideoSyncProcessing;
import me.zhengjie.modules.sync.processing.PropertyVrSyncProcessing;
import me.zhengjie.modules.sync.pull.ProContactSync;
import me.zhengjie.modules.sync.pull.ProVideoSync;
import me.zhengjie.modules.sync.pull.ProVrSync;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class PropertyRelationPullTask extends PullTaskBase{
    @Autowired
    private ProVideoSync proVideoSync;
    @Autowired
    private ProVrSync proVrSync;
    @Autowired
    private ProContactSync proContactSync;

    public PropertyRelationPullTask() {
        setTaskName(this.getClass().getSimpleName());
    }

    public void pull(SyncCommon syncCommon, Date date){
        //视频
        log.info("run companyUuid {} proVideoSync start ", syncCommon.getCompanyUuid());
        Long startTime = System.currentTimeMillis();
        proVideoSync.pull(syncCommon, date);
        Long endTime = System.currentTimeMillis();
        log.info("run companyUuid {} proVideoSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

        //VR
        log.info("run companyUuid {} proVrSync start ", syncCommon.getCompanyUuid());
        startTime = System.currentTimeMillis();
        proVrSync.pull(syncCommon, date);
        endTime = System.currentTimeMillis();
        log.info("run companyUuid {} proVrSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));

        //业主
        log.info("run companyUuid {} proContactSync start ", syncCommon.getCompanyUuid());
        startTime = System.currentTimeMillis();
        proContactSync.pull(syncCommon, date);
        endTime = System.currentTimeMillis();
        log.info("run companyUuid {} proContactSync end {} ", syncCommon.getCompanyUuid(), (endTime - startTime));
    }
}
